package com.yhq.sensitive.strategy;

import com.yhq.sensitive.enums.SensitiveDefaultLengthEnum;
import com.yhq.sensitive.util.SensitiveUtils;

/**
 * 手机号码脱敏
 *
 * @author yhq
 * @date 2021年9月6日 16点13分
 **/
public class SensitiveMobilePhone implements IStrategy {

    @Override
    public String desensitization(String mobile, int begin, int end) {
        if (begin != SensitiveDefaultLengthEnum.MOBILE_PHONE.getBegin() && begin != 0 &&
                end != SensitiveDefaultLengthEnum.MOBILE_PHONE.getEnd() && end != 0) {
            return SensitiveUtils.mobilePhone(mobile, begin, end);
        }
        return SensitiveUtils.mobilePhone(mobile, SensitiveDefaultLengthEnum.MOBILE_PHONE.getBegin(), SensitiveDefaultLengthEnum.MOBILE_PHONE.getEnd());
    }

}
